<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="关联产品" prop="pid">
        <el-input
          v-model="queryParams.pid"
          placeholder="请输入关联产品"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="适配OS" prop="paOs">
        <el-select v-model="queryParams.paOs" placeholder="请选择适配OS" clearable>
          <el-option
            v-for="dict in dict.type.audition_os"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="适配时间">
        <el-date-picker
          v-model="daterangePaTime"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="适配OS类型" prop="paType">
        <el-select v-model="queryParams.paType" placeholder="请选择适配OS类型" clearable>
          <el-option
            v-for="dict in dict.type.auditiing_os_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="适配状态" prop="paState">
        <el-select v-model="queryParams.paState" placeholder="请选择适配状态" clearable>
          <el-option
            v-for="dict in dict.type.auditing_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="适配OS版本" prop="paVersion">
        <el-input
          v-model="queryParams.paVersion"
          placeholder="请输入适配OS版本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="兼容等级" prop="paLevel">
        <el-select v-model="queryParams.paLevel" placeholder="请选择兼容等级" clearable>
          <el-option
            v-for="dict in dict.type.compatibility_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="OS小版本" prop="paMinVersion">
        <el-input
          v-model="queryParams.paMinVersion"
          placeholder="请输入OS小版本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="认证状态" prop="paAuthenticationStatus">
        <el-select v-model="queryParams.paAuthenticationStatus" placeholder="请选择认证状态" clearable>
          <el-option
            v-for="dict in dict.type.certification_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="适配平台" prop="paPlatform">
        <el-select v-model="queryParams.paPlatform" placeholder="请选择适配平台" clearable>
          <el-option
            v-for="dict in dict.type.adaptation_platform"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="收费/免费" prop="paCost">
        <el-input
          v-model="queryParams.paCost"
          placeholder="请输入收费/免费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="适配CPU型号" prop="paCpu">
        <el-select v-model="queryParams.paCpu" placeholder="请选择适配CPU型号" clearable>
          <el-option
            v-for="dict in dict.type.adapted_cpu_model"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="上架情况" prop="paListing">
        <el-select v-model="queryParams.paListing" placeholder="请选择上架情况" clearable>
          <el-option
            v-for="dict in dict.type.auditing_listing"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="适配验证情况" prop="paValidate">
        <el-select v-model="queryParams.paValidate" placeholder="请选择适配验证情况" clearable>
          <el-option
            v-for="dict in dict.type.adaptation_verification_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['info:adaptation:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['info:adaptation:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['info:adaptation:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['info:adaptation:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="data" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="${comment}" align="center" prop="id" />
      <el-table-column label="关联产品" align="center" prop="pid" />
      <el-table-column label="适配OS" align="center" prop="paOs">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.audition_os" :value="scope.row.paOs"/>
        </template>
      </el-table-column>
      <el-table-column label="适配时间" align="center" prop="paTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.paTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="适配OS类型" align="center" prop="paType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.auditiing_os_type" :value="scope.row.paType"/>
        </template>
      </el-table-column>
      <el-table-column label="适配状态" align="center" prop="paState">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.auditing_status" :value="scope.row.paState"/>
        </template>
      </el-table-column>
      <el-table-column label="适配OS版本" align="center" prop="paVersion" />
      <el-table-column label="兼容等级" align="center" prop="paLevel">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.compatibility_level" :value="scope.row.paLevel"/>
        </template>
      </el-table-column>
      <el-table-column label="OS小版本" align="center" prop="paMinVersion" />
      <el-table-column label="认证状态" align="center" prop="paAuthenticationStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.certification_status" :value="scope.row.paAuthenticationStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="适配平台" align="center" prop="paPlatform">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.adaptation_platform" :value="scope.row.paPlatform"/>
        </template>
      </el-table-column>
      <el-table-column label="收费/免费" align="center" prop="paCost" />
      <el-table-column label="适配CPU型号" align="center" prop="paCpu">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.adapted_cpu_model" :value="scope.row.paCpu"/>
        </template>
      </el-table-column>
      <el-table-column label="上架情况" align="center" prop="paListing">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.auditing_listing" :value="scope.row.paListing"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="paRemark" />
      <el-table-column label="适配验证情况" align="center" prop="paValidate">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.adaptation_verification_status" :value="scope.row.paValidate"/>
        </template>
      </el-table-column>
      <el-table-column label="安装使用文档" align="center" prop="paUsingDocuments" />
      <el-table-column label="适配产品安装包" align="center" prop="paInstallPackage" />
      <el-table-column label="产品状态 1:待审核 2:不合格 3:正常" align="center" prop="paStatus" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['info:adaptation:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['info:adaptation:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import ListMixin from "@/minixs/list"
import request from "@/utils/request";
export default {
  name: "list",
  mixins:[ListMixin],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pid: null,
        paOs: null,
        paTime: null,
        paType: null,
        paState: null,
        paVersion: null,
        paLevel: null,
        paMinVersion: null,
        paAuthenticationStatus: null,
        paPlatform: null,
        paCost: null,
        paCpu: null,
        paListing: null,
        paRemark: null,
        paValidate: null,
        paStatus: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询适配信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangePaTime && '' != this.daterangePaTime) {
        this.queryParams.params["beginPaTime"] = this.daterangePaTime[0];
        this.queryParams.params["endPaTime"] = this.daterangePaTime[1];
      }
      request({
        url: '/info/adaptation/list',
        method: 'get',
        params: this.queryParams
      }).then(response => {
        this.data = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('/info/adaptation/export', {
        ...this.queryParams
      }, `adaptation_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
